import 'package:get/get.dart';

import 'state.dart';

class GetxVcLogic extends GetxController {
  final GetxVcState state = GetxVcState();
  var count = 0.obs;
  @override
  void onReady() {
    // TODO: implement onReady
    print('getxVc-onReady');
    super.onReady();

  }
  @override
  void onInit() {
    // TODO: implement onInit
    print('getxVc-onInit');
    // 监听count的值,当它发生改变的时候调用
    ever(count, (callback) => print("ever----$count"));

    // 监听多个值,当它们发生改变的时候调用
    // everAll([count], (callback) => print("everAll----$count"));

    // count值改变时调用,只执行一次
    once(count, (callback) => print("once----$count"));

    // 用户停止打字时1秒后调用,主要是防DDos
    debounce(count, (callback) => print("debounce----$count"));

    // 忽略3秒内的所有变动
    interval(count, (callback) => print("interval----$count"));

    super.onInit();
  }
  @override
  void onClose() {
    // TODO: implement onClose
    print('getxVc-onClose');
    super.onClose();

  }

  void increase(){
    // count++;
    state.count++;
    update();
  }

}
